package com.masterclient.app.businessmodule.vipmodule.card;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.masterclient.app.R;
import com.masterclient.app.businessmodule.vipmodule.bean.Level;
import com.masterclient.app.widget.GlideRoundTransform;
import butterknife.BindView;

/**
 * vip会员
 */
public class VipCard extends IBaseCard<Level> {
    @BindView(R.id.bg_iv)
    ImageView bgIv;
    @BindView(R.id.title1_tv)
    TextView title1Tv;
    @BindView(R.id.pro_tv)
    TextView proTv;
    @BindView(R.id.open_tv)
    TextView openTv;
    @BindView(R.id.progress)
    ProgressBar progress;
    private RequestOptions options;
    public VipCard(View itemView, Context context) {
        super(itemView, context);
        options = new RequestOptions();
        options.transform(new GlideRoundTransform(context, 8,GlideRoundTransform.RADIUSTOP));
    }

    @Override
    public void onBindViewHolder(Level level, int i) {
        String name = level.getLevel_name();
        String eName = level.getLevel_english_name();
        title1Tv.setText(name+"　"+eName);
        String bg = level.getLevel_bg();
        Glide.with(mContext).load(bg).apply(options).into(bgIv);
        openTv.setText(level.getBtnText());
        if(level.getCurrentLevel()==level.getLevel()){
            progress.setVisibility(View.VISIBLE);
            proTv.setVisibility(View.VISIBLE);
            float customerExp = level.getCustomer_expF();
            float levelExp  = level.getLevel_expF();
            proTv.setText(level.getCustomer_exp()+"/"+level.getLevel_exp());
            float pro = customerExp/levelExp*100;
            progress.setProgress((int) pro);
        }else {
            progress.setVisibility(View.GONE);
            proTv.setVisibility(View.GONE);
        }

    }

}
